﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotNetNuke.Entities.Content;
using DotNetNuke.Common.Utilities;

namespace DotNetNuke.Modules.mytargetmodule.Components
{
    public class Task:ContentItem
    {
        public int TaskID { get; set; }
        public string Taskname { get; set; }
        public string TaskDescription { get; set; }
        public int AssignedUserID { get; set; }
        public int ModuleID { get; set; }
        public DateTime TargetCompletionDAte { get; set; }
        public DateTime CompletedCndate { get; set; }
        public int ContentItemID { get; set; }
        public DateTime CreatedDate { get; set; }
        public int CreatedByUserID { get; set; }
        public DateTime LastModifiedOnDate { get; set; }
        public int LastModifiedbyUserID { get; set; }
        public int PortalID { get; set; } 
        public string createdByUser
        {
            get
            {
                return CreatedByUserID != 0 ? Entities.Users.UserController.GetUserById(PortalID, CreatedByUserID).Username : Null.NullString;
                }
        }

        public string LastUpdatedByUser
        {
            get {
                  return LastModifiedbyUserID != 0 ? Entities.Users.UserController.GetUserById(PortalID, LastModifiedbyUserID).Username : Null.NullString;
                }
        }

        public override void Fill(System.Data.IDataReader dr)
        {
            //base.Fill(dr);
            base.FillInternal(dr);
            TaskID = Null.SetNullInteger(dr["TaskId"]);
            Taskname = Null.SetNullString(dr["Taskname"]);
            TaskDescription = Null.SetNullString(dr["TaskDescription"]);
            AssignedUserID = Null.SetNullInteger(dr["AssignedUserID"]);
            ModuleID= Null.SetNullInteger(dr["ModuleID"]);
            TargetCompletionDAte = Null.SetNullDateTime(dr["TargetCompletionDAte"]);
            CompletedCndate = Null.SetNullDateTime(dr["CompletedCndate"]);
            ContentItemID = Null.SetNullInteger(dr["ContentItemID"]);
            CreatedDate = Null.SetNullDateTime(dr["CreatedDate"]);
            CreatedByUserID = Null.SetNullInteger(dr["CreatedByUserID"]);
            LastModifiedOnDate = Null.SetNullDateTime(dr["LastModifiedOnDate"]);
            LastModifiedbyUserID = Null.SetNullInteger(dr["LastModifiedbyUserID"]);
        }
        public override int KeyID
        {
            get
            {
                return TaskID;
            }
            set
            {
                TaskID = value;
            }
        }
    }
}